﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS;
using ESRI.ArcGIS.Geometry;

namespace Test
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {


            RuntimeManager.BindLicense(ProductCode.EngineOrDesktop);


            var line = new PolylineClass();

            var point0 = new PointClass()
            {
                X = 1,
                Y = 1
            };

            var point1 = new PointClass()
            {
                X = 4,
                Y = 0
            };
            var point2 = new PointClass()
            {
                X = 5,
                Y = 11
            };
            var point3 = new PointClass()
            {
                X = -1,
                Y = 1
            };
            var point4 = new PointClass()
            {
                X = 2,
                Y = 7
            };

            ((IPointCollection)line).AddPoint(point3);
            ((IPointCollection)line).AddPoint(point4);


            var polygon = new PolygonClass();

            ((IPointCollection)polygon).AddPoint(point0);
            ((IPointCollection)polygon).AddPoint(point1);
            ((IPointCollection)polygon).AddPoint(point2);

            var outGeom = ((ITopologicalOperator)polygon).Intersect(line, esriGeometryDimension.esriGeometry1Dimension);

            var length = ((IPolyline)outGeom).Length;

            ;
        }
    }
}
